package LuoGu.二分查找.砍树;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
        StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        st.nextToken();
        int n = (int) st.nval;
        st.nextToken();
        long tt = (long) st.nval;
        long [] temp = new long [n];
        for(int i=0;i<n;i++){
            st.nextToken();
            temp[i] = (long) st.nval;
        }
        Arrays.sort(temp);
        long l = 0;
        long r = temp[n-1];
        long m;
        //请注意本题的中间值，一定要头脑清醒；
        while(l<r){
            long temppp = 0;
            m = (r-l)/2+l;
            for(int i=0;i<n;i++){
                if(temp[i]>m){
                    temppp+=(temp[i]-m);
                }
            }
            if(temppp>=tt) l = m+1;
            else r = m;
        }
        System.out.print(l-1);
    }
}
